import 'package:file_picker/file_picker.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
import 'package:smart_devices/form/device_add_form.dart';

class DeviceAddLogic extends GetxController {
  Rx<DeviceAddForm> form = Rx(DeviceAddForm());
  RxList<XFile> imgs = RxList([]);
  RxList<PlatformFile> files = RxList([]);
  Rx<TextEditingController> buyUserController = Rx(TextEditingController());
  Rx<TextEditingController> buyDeptController = Rx(TextEditingController());
  Rx<TextEditingController> departmentController = Rx(TextEditingController());
  Rx<TextEditingController> userController = Rx(TextEditingController());
  Rx<TextEditingController> typeController = Rx(TextEditingController());
  Rx<TextEditingController> statusController = Rx(TextEditingController());
  Rx<TextEditingController> locationController = Rx(TextEditingController());
  Rx<TextEditingController> startDateController = Rx(TextEditingController());
  Rx<TextEditingController> orderController = Rx(TextEditingController());
  Rx<TextEditingController> supplierController = Rx(TextEditingController());
  Rx<TextEditingController> buyDateController = Rx(TextEditingController());
  Rx<TextEditingController> leaveFactoryDateController =
      Rx(TextEditingController());

  @override
  void onClose() {
    super.onClose();
    buyUserController.value.dispose();
    buyDeptController.value.dispose();
    departmentController.value.dispose();
    userController.value.dispose();
    typeController.value.dispose();
    statusController.value.dispose();
    locationController.value.dispose();
    startDateController.value.dispose();
    orderController.value.dispose();
    supplierController.value.dispose();
    buyDateController.value.dispose();
    leaveFactoryDateController.value.dispose();
  }

  void uploadFilePath(List<XFile> res) {
    imgs.addAll(res);
  }
}
